package cn.myschool.myschool.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
//分页对象
public class Page<T> implements Serializable {
    public static final int PAGESIZE=10;
    private int code=0;//表示是否成功，0表示成功，其他表示不成功
    //本页的数据
    private List<T> datas = new ArrayList<>(0);
    private int pageNo = 1;///页码
    private int count;//总条数
    private int pageTotal;//总页数
    private int pageSize = PAGESIZE;//每页条数

    public Page(){

    }
    public Page(List<T> datas,int total, int pageSize) {
        this.datas = datas;
//        this.count = count;
        this.setCount(total);
        this.pageSize = pageSize;
    }
    public Page(List<T> datas, int pageNo, int total, int pageSize) {
        this.datas = datas;
        this.pageNo = pageNo;
//        this.count = count;
        this.setCount(total);
        this.pageSize = pageSize;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<T> getDatas() {
        return datas;
    }

    public void setDatas(List<T> datas) {
        this.datas = datas;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
        this.pageTotal = this.count / this.pageSize + (this.count % this.pageSize == 0 ? 0 : 1);
    }

    public int getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(int pageTotal) {
        this.pageTotal = pageTotal;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
